package com.team.employment.web.admin.controller.company;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.team.employment.common.result.Result;
import com.team.employment.model.entity.CompanyInfo;
import com.team.employment.model.entity.CompanyStatutory;
import com.team.employment.model.entity.RecruitmentInfo;
import com.team.employment.model.entity.StatutoryInfo;
import com.team.employment.web.admin.service.*;
import com.team.employment.web.admin.vo.BenefitDetailVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "企业关联信息查询")
@RestController
@RequestMapping("/admin/companyRelated")
public class CompanyRelatedController {

    @Autowired
    private CompanyTypeService companyTypeService;

    @Autowired
    private RecruitmentInfoService recruitmentInfoService;

    @Autowired
    private StatutoryInfoService statutoryInfoService;

    @Autowired
    private BenefitInfoService benefitInfoService;

    @Operation(summary = "根据一级职位类型id查找公司")
    @GetMapping("getCompanyById/{id}")
    public Result<List<CompanyInfo>> getTypeById(@PathVariable  Long id){
        List<CompanyInfo> list = companyTypeService.getTypeById(id);
        return Result.ok(list);
    }

    @Operation(summary = "根据company_id查看单个企业的招聘信息")
    @GetMapping("getRecruitmentById/{id}")
    public Result<List<RecruitmentInfo>> getRecruitmentById(@PathVariable  Long id){
        LambdaQueryWrapper<RecruitmentInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(RecruitmentInfo::getCompanyId,id);
        List<RecruitmentInfo> list = recruitmentInfoService.list(lambdaQueryWrapper);
        return Result.ok(list);
    }

    @Operation(summary = "根据company_id查看单个企业的法定人信息")
    @GetMapping("getStatutoryById/{id}")
    public Result<StatutoryInfo> getStatutoryById(@PathVariable  Long id){
        StatutoryInfo statutoryInfo = statutoryInfoService.getStatutoryById(id);
        return Result.ok(statutoryInfo);
    }

    @Operation(summary = "根据Benefits_id查询福利详细信息")
    @GetMapping("getCompanyBenefit/{id}")
    public Result<BenefitDetailVo> getCompanyBenefit(@PathVariable  Long id){
        BenefitDetailVo list = benefitInfoService.getCompanyBenefit(id);
        return Result.ok(list);
    }
}
